package com.person.controller;

import com.person.common.CommonResult;
import com.person.service.ProviderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@Slf4j
public class ProviderController {

    @Resource
    private ProviderService providerService;

    @Value("${server.port}")
    private String serverPort;

    @GetMapping("/peyment/hystrix/ok/{id}")
    public CommonResult paymentInfo_ok(@PathVariable("id") Integer id) {
        return providerService.paymentInfo_ok(id);
    }


    @GetMapping("/payment/hystrix/timeout/{id}")
    public CommonResult paymentInfo_timeout(@PathVariable("id") Integer id) {
        return providerService.paymentInfo_timeout(id);
    }


    @GetMapping("/payment/hystrix/breaker/{id}")
    public CommonResult paymentBreaker(@PathVariable("id")Integer id){
        log.info("request **********+"+ id);
        return providerService.paymentCircuitBreaker(id);
    }

}
